package comparable_test;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张宇田
 * Date: 2024-10-11
 * Time: 17:57
 */
public class Student implements Comparable <Student>{
    public String name;
    private int score;

    public Student(String name, int score) {
        this.name = name;
        this.score = score;

    }
    //实现接口里的方法
    //this 是调用函数的变量 o 是比较的量
    public int compareTo(Student o){
        return this.score - o.score;
    }
    public String toString() {
        return "[" + this.name + ":" + this.score + "]";
    }

}
